$(document).ready(function(){
  
	$('#calendar').datepicker({
		inline: true,
		firstDay: 7,
		showOtherMonths: true,
		dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
		onChangeMonthYear: changeBackground
	});
 
	function changeBackground(year, month, obj){
		var months = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
		
		months.forEach(function(value){
			$('.calendar_img').removeClass(value);
		});
		
		$('.calendar_img').addClass(months[month - 1]);
	}
  
	var month = $('.ui-datepicker-month').text().toLowerCase();
	$('.calendar_img').addClass(month);
  
})